package com.woniu.supermarket.util;

import java.util.UUID;

public class CodeCreateUtil {

    /**
     * 创造一个商品编码
     * @return string 630+12位编码
     */
    public static String createGoodsCode(){
        String gcode = "630";
        String ucode = UUID.randomUUID().toString().replaceAll("-","").substring(0,12);

        gcode += ucode;
        return gcode;
    }

    /**
     * 创造一个商品品牌编码
     * @param id  给予一个id值
     * @return    六位  前补0 的id
     */
    public static String createGoodsBrandCode(int id){

        String gbcode = "000000"+id;
        gbcode = gbcode.substring(gbcode.length()-6);

        return gbcode;
    }

    /**
     * 创造一个商品单位编码
     * @param id  给予一个id值
     * @return    三位  前补0 的id
     */
    public static String createGoodsUnitCode(int id){
        String gucode = "000"+id;
        gucode = gucode.substring(gucode.length()-3);
        return gucode;
    }

    /**
     * 创造一个采购单编码
     * @return   CGCG+ 11位uuid
     */
    public static String createPurchaseCode(){
        String cpcode = "CGCG";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cpcode += ucode;
        return cpcode;
    }


    /**
     * 创造一个采购明细单编码
     * @return   CGMX+ 11位uuid
     */
    public static String createPurchaseDetailCode(){
        String cpdcode = "CGMX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cpdcode += ucode;
        return cpdcode;
    }

    /**
     * 创造一个采购退货单编码
     * @return   CGTH+ 11位uuid
     */
    public static String createPurchaseReturnCode(){
        String cprcode = "CGTH";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cprcode += ucode;
        return cprcode;
    }

    /**
     * 创造一个采购退货明细单编码
     * @return   CTMX+ 11位uuid
     */
    public static String createPurchaseReturnDetailCode(){
        String cprdcode = "CTMX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cprdcode += ucode;
        return cprdcode;
    }

    /**
     * 创造一个入库单编码
     * @return   RKRK+ 11位uuid
     */
    public static String createWarehousingCode(){
        String cwcode = "RKRK";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cwcode += ucode;
        return cwcode;
    }

    /**
     * 创造一个入库明细单编码
     * @return   RKMX+ 11位uuid
     */
    public static String createWarehousingDetailCode(){
        String cwdcode = "RKMX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cwdcode += ucode;
        return cwdcode;
    }

    /**
     * 创造一个出库单编码
     * @return   CKCK+ 11位uuid
     */
    public static String createOutboundCode(){
        String cocode = "CKCK";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cocode += ucode;
        return cocode;
    }

    /**
     * 创造一个出库明细单编码
     * @return   CKMX+ 11位uuid
     */
    public static String createOutboundDetailCode(){
        String codcode = "CKMX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        codcode += ucode;
        return codcode;
    }

    /**
     * 创造一个促销单编码
     * @return   CXCX+ 11位uuid
     */
    public static String createPromotionCode(){
        String cpcode = "CXCX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cpcode += ucode;
        return cpcode;
    }

    /**
     * 创造一个促销明细单编码
     * @return   CXMX+ 11位uuid
     */
    public static String createPromotionDetailCode(){
        String cpdcode = "CXMX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cpdcode += ucode;
        return cpdcode;
    }

    /**
     * 创造一个销售单编码
     * @return   XSXS+ 11位uuid
     */
    public static String createSalesCode(){
        String cscode = "XSXS";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cscode += ucode;
        return cscode;
    }

    /**
     * 创造一个销售明细单编码
     * @return   XSMX+ 11位uuid
     */
    public static String createSalesDetailCode(){
        String csdcode = "XSMX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        csdcode += ucode;
        return csdcode;
    }

    /**
     * 创造一个销售退货单编码
     * @return   XSTH+ 11位uuid
     */
    public static String createSalesReturnCode(){
        String csrcode = "XSTH";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        csrcode += ucode;
        return csrcode;
    }

    /**
     * 创造一个销售退货明细单编码
     * @return   XTMX+ 11位uuid
     */
    public static String createSalesReturnDetailCode(){
        String csrdcode = "XTMX";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        csrdcode += ucode;
        return csrdcode;
    }

    /**
     * 创造一个财务收款单编码
     * @return   SKSK+ 11位uuid
     */
    public static String createReceiptCode(){
        String crcode = "SKSK";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        crcode += ucode;
        return crcode;
    }

    /**
     * 创造一个财务退款单编码
     * @return   TKTK+ 11位uuid
     */
    public static String createRefundsCode(){
        String crcode = "TKTK";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        crcode += ucode;
        return crcode;
    }

    /**
     * 创造一个会员编码
     * @return   SMEM+ 11位uuid
     */
    public static String createMemberCode(){
        String cmcode = "SMEM";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cmcode += ucode;
        return cmcode;
    }

    /**
     * 创造一个门店号
     * @param id   门店id
     * @return   3位+id 0补齐
     */
    public static String createStorefrontCode(int id){
        String cscode = "000"+id;
        cscode = cscode.substring(cscode.length()-3);
        return cscode;
    }


    /**
     * 创造一个员工工号
     * 无参
     * @return   E001+ 11位uuid
     */
    public static String createEmployeeCode(){
        String cecode = "E001";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cecode += ucode;
        return cecode;
    }

    /**
     * 创造一个员工工号
     * @param   id 门店 id
     * @return   E+根据门店id生成一个门店号+ 11位uuid
     */
    public static String createEmployeeCode(int id){
        String cecode = "E"+CodeCreateUtil.createStorefrontCode(id);
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cecode += ucode;
        return cecode;
    }

    /**
     * 创造一个权限编号
     * @param   id 权限 id
     * @return   id+0补全10位
     */
    public static String createPermissionCode(int id){
        String cpcode = "0000000000"+id;
        cpcode = cpcode.substring(cpcode.length()-10);
        return cpcode;
    }

    /**
     * 创造一个门店编码
     * @return   SHOP+ 11位uuid
     */
    public static String createShopCode(){
        String cscode = "SHOP";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cscode += ucode;
        return cscode;
    }


    public static String createStockTakingCode(){
        String cscode = "PD";
        String ucode = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 11);
        cscode += ucode;
        return cscode;
    }

}
